//获取当前时间

import {useState,useEffect,}from 'react';
import moment ,{Moment} from 'moment'
import{useDispatch} from 'react-redux'
export default function Zooks(){
  const dispatch=useDispatch()
  const [time,setTime] = useState(moment().month(2))
  return(
     <div className='wrap'>
       <Time/>
     </div>
  )
}
function Time(){
  const [now,setNow] =useState(moment())
  useEffect(()=>{
    const t =setInterval(()=>{
      setNow(moment())
    },1000)

    return()=>{
      clearInterval(t)
    }
  },[])
  return(
    <div>
      <span className='time-date'>{now.format('YYYY-MM-DD')} {now.format('HH:mm:ss')}</span>
     
    </div>
  )
}